package com.android.lovingpet.util;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;

import com.android.lovingpet.Application;

/**
 * Created by ikata on 2018/6/19.
 */

public class SpUtil {

    public static void setLocation(double longitude,double latitude,String address)
    {
        @SuppressLint("CommitPrefEdits") SharedPreferences.Editor editor= Application.getContext().getSharedPreferences("location", Context.MODE_PRIVATE).edit();
        editor.putString("longitude", String.valueOf(longitude));
        editor.putString("latitude", String.valueOf(latitude));
        editor.putString("city",address);
        editor.apply();
    }
    public static String getLongitude()
    {
        SharedPreferences sharedPreferences=Application.getContext().getSharedPreferences("lacation",Context.MODE_PRIVATE);
        return sharedPreferences.getString("longitude","0.00");
    }

    public static String getLatitude()
    {
        SharedPreferences sharedPreferences=Application.getContext().getSharedPreferences("lacation",Context.MODE_PRIVATE);
        return sharedPreferences.getString("latitude","0.00");
    }

    public static String getCity()
    {
        SharedPreferences sharedPreferences=Application.getContext().getSharedPreferences("lacation",Context.MODE_PRIVATE);
        return sharedPreferences.getString("city",null);
    }
}
